package com.eastfair.home.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 服务项
 * </p>
 *
 * @author linan
 * @date 2022-07-28
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "HomeServiceItemAuditStateEnum", description = "审核状态 #{DEFAULT:默认;APPROVED:已审核;NOT_APPROVED:未审核-枚举")
public enum HomeServiceItemAuditStateEnum implements BaseEnum {

    /**
     * DEFAULT="默认"
     */
    DEFAULT("默认"),
    /**
     * APPROVED="已审核"
     */
    APPROVED("已审核"),
    /**
     * NOT_APPROVED="未审核"
     */
    NOT_APPROVED("未审核"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static HomeServiceItemAuditStateEnum match(String val, HomeServiceItemAuditStateEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static HomeServiceItemAuditStateEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(HomeServiceItemAuditStateEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "DEFAULT,APPROVED,NOT_APPROVED", example = "DEFAULT")
    public String getCode() {
        return this.name();
    }

}
